package com.luckberry.murder.mapper;

import com.luckberry.murder.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user")
    List<User> getUsers();

    @Select("select * from user where name like '%' #{name} '%'")
    List<User> getUsersByName(String name);

    @Select("select * from user where perm = #{type}")
    List<User> getUsersByPerm(String perm);

    @Select("select * from user where uid = #{uid}")
    User getUser(int uid);

    @Select("select * from user where account = #{account}")
    User getUserByAccount(String account);

    @Insert("insert into user(name, account, password, perm, face) VALUES (#{name}, #{account}, #{password}, #{perm}, #{face})")
    int addUser(User user);

    @Delete("delete user from user where uid = #{uid}")
    int deleteUser(int uid);

    @Update("update user set name = #{name}, account = #{account}, password = #{password}, perm = #{perm}, face = #{face} where uid = #{uid}")
    int editUser(User user);
}
